🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / androidApp / src / google / kotlin / org / meshtastic / app / map / offline / pmtiles / WebMercatorTileMath.kt
Displaying Raw • Download
androidApp/src/google/kotlin/org/meshtastic/app/map/offline/pmtiles/WebMercatorTileMath.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 3.11 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map.offline.pmtiles
Tff7b72import T7ee787com.google.android.gms.maps.model.LatLng
Tff7b72import T7ee787kotlin.math.PI
Tff7b72import T7ee787kotlin.math.asinh
Tff7b72import T7ee787kotlin.math.atan
Tff7b72import T7ee787kotlin.math.pow
Tff7b72import T7ee787kotlin.math.sinh
Tff7b72import T7ee787kotlin.math.tan
T8b949e/** Standard XYZ/slippy-map Web Mercator conversions, shared by tile enumeration and MVT-local-coordinate placement. */
Tff7b72internal Tff7b72object T56d364WebMercatorTileMath Tb4b4b4{
T8b949e/** The tile (at [zoom]) containing [latLng] — the same indexing GoogleMap, MapLibre and PMTiles all share. */
Tff7b72fun Td2a8fftileAtTb4b4b4(Te6edf3zoomTb4b4b4: Tffa657IntTb4b4b4, Te6edf3latLngTb4b4b4: Te6edf3LatLngTb4b4b4)Tb4b4b4: Te6edf3TileIndex Tb4b4b4{
Tff7b72val Te6edf3n Tff7b72= T79c0ff2.0Tb4b4b4.Te6edf3powTb4b4b4(Te6edf3zoomTb4b4b4)
Tff7b72val Te6edf3latRad Tff7b72= Te6edf3MathTb4b4b4.Te6edf3toRadiansTb4b4b4(Te6edf3latLngTb4b4b4.Te6edf3latitudeTb4b4b4.Te6edf3coerceInTb4b4b4(Tff7b72-Te6edf3MAX_LATITUDETb4b4b4, Te6edf3MAX_LATITUDETb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3x Tff7b72= Tb4b4b4(Tb4b4b4(Te6edf3latLngTb4b4b4.Te6edf3longitude Tff7b72+ Te6edf3LON_RANGE_DEGTb4b4b4) Tff7b72/ Te6edf3FULL_LON_RANGE_DEG Tff7b72* Te6edf3nTb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3coerceInTb4b4b4(T79c0ff0Tb4b4b4, Tb4b4b4(Te6edf3n Tff7b72- T79c0ff1Tb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3y Tff7b72= Tb4b4b4(Tb4b4b4(T79c0ff1.0 Tff7b72- Te6edf3asinhTb4b4b4(Te6edf3tanTb4b4b4(Te6edf3latRadTb4b4b4)Tb4b4b4) Tff7b72/ Te6edf3PITb4b4b4) Tff7b72/ T79c0ff2.0 Tff7b72* Te6edf3nTb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3coerceInTb4b4b4(T79c0ff0Tb4b4b4, Tb4b4b4(Te6edf3n Tff7b72- T79c0ff1Tb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72return Te6edf3TileIndexTb4b4b4(Te6edf3zoomTb4b4b4, Te6edf3xTb4b4b4, Te6edf3yTb4b4b4)
Tb4b4b4}
T8b949e/** Places a feature's tile-local point (`0 until extent` on each axis) at its real-world [LatLng]. */
Tff7b72fun Td2a8fftileLocalToLatLngTb4b4b4(Te6edf3tileTb4b4b4: Te6edf3TileIndexTb4b4b4, Te6edf3extentTb4b4b4: Tffa657IntTb4b4b4, Te6edf3localTb4b4b4: Te6edf3TileCoordTb4b4b4)Tb4b4b4: Te6edf3LatLng Tff7b72=
Te6edf3tileFractionalToLatLngTb4b4b4(Te6edf3tileTb4b4b4.Te6edf3zoomTb4b4b4, Te6edf3tileTb4b4b4.Te6edf3xTb4b4b4, Te6edf3tileTb4b4b4.Te6edf3yTb4b4b4, Te6edf3localTb4b4b4.Te6edf3xTb4b4b4.Te6edf3toDoubleTb4b4b4(Tb4b4b4) Tff7b72/ Te6edf3extentTb4b4b4, Te6edf3localTb4b4b4.Te6edf3yTb4b4b4.Te6edf3toDoubleTb4b4b4(Tb4b4b4) Tff7b72/ Te6edf3extentTb4b4b4)
T8b949e/**
* Places a fractional `[0,1]×[0,1]` tile-local point — [org.meshtastic.feature.map.terrain.ContourPoint]'s own
* convention — at its real-world [LatLng]. A standalone zoom/x/y overload rather than one keyed by this file's own
* [TileIndex], so callers outside this package (the offline terrain contour renderer, which has its own same-shaped
* but distinct `TileIndex`) can reuse this math without a type-conversion shim.
*/
Tff7b72fun Td2a8fftileFractionalToLatLngTb4b4b4(Te6edf3zoomTb4b4b4: Tffa657IntTb4b4b4, Te6edf3tileXTb4b4b4: Tffa657IntTb4b4b4, Te6edf3tileYTb4b4b4: Tffa657IntTb4b4b4, Te6edf3fracXTb4b4b4: Tffa657DoubleTb4b4b4, Te6edf3fracYTb4b4b4: Tffa657DoubleTb4b4b4)Tb4b4b4: Te6edf3LatLng Tb4b4b4{
Tff7b72val Te6edf3n Tff7b72= T79c0ff2.0Tb4b4b4.Te6edf3powTb4b4b4(Te6edf3zoomTb4b4b4)
Tff7b72val Te6edf3fx Tff7b72= Te6edf3tileX Tff7b72+ Te6edf3fracX
Tff7b72val Te6edf3fy Tff7b72= Te6edf3tileY Tff7b72+ Te6edf3fracY
Tff7b72val Te6edf3lon Tff7b72= Te6edf3fx Tff7b72/ Te6edf3n Tff7b72* Te6edf3FULL_LON_RANGE_DEG Tff7b72- Te6edf3LON_RANGE_DEG
Tff7b72val Te6edf3latRad Tff7b72= Te6edf3atanTb4b4b4(Te6edf3sinhTb4b4b4(Te6edf3PI Tff7b72* Tb4b4b4(T79c0ff1 Tff7b72- T79c0ff2 Tff7b72* Te6edf3fy Tff7b72/ Te6edf3nTb4b4b4)Tb4b4b4)Tb4b4b4)
Tff7b72return Te6edf3LatLngTb4b4b4(Te6edf3MathTb4b4b4.Te6edf3toDegreesTb4b4b4(Te6edf3latRadTb4b4b4)Tb4b4b4, Te6edf3lonTb4b4b4)
Tb4b4b4}
Tff7b72private Tff7b72const Tff7b72val Te6edf3LON_RANGE_DEG Tff7b72= T79c0ff1T79c0ff8T79c0ff0.0
Tff7b72private Tff7b72const Tff7b72val Te6edf3FULL_LON_RANGE_DEG Tff7b72= T79c0ff3T79c0ff6T79c0ff0.0
T8b949e/** Web Mercator's own latitude ceiling (~85.0511°), where the projection would otherwise reach infinity. */
Tff7b72private Tff7b72const Tff7b72val Te6edf3MAX_LATITUDE Tff7b72= T79c0ff8T79c0ff5.05112878
Tb4b4b4}
Tff7b72internal Tff7b72data Tff7b72class T56d364TileIndexTb4b4b4(Tff7b72val Te6edf3zoomTb4b4b4: Tffa657IntTb4b4b4, Tff7b72val Te6edf3xTb4b4b4: Tffa657IntTb4b4b4, Tff7b72val Te6edf3yTb4b4b4: Tffa657IntTb4b4b4)
Served by rngit 1.5.2 - Generated in 0.08s